package com.gitee.wsl.mathematics.function.noise.d2

import com.gitee.wsl.mathematics.function.noise.Noise2d
import com.gitee.wsl.mathematics.vector.vec2.Vec2f

class ScaledNoise2d(
    val noise: Noise2d,
    val amplitude: Float = 1f,
    val scale: Float = 1f,
    val center: Vec2f = Vec2f.ZERO
) : Noise2d {
    override fun eval(x: Float, y: Float): Float {
        return noise.eval(center.x + x * scale, center.y + y * scale) * amplitude
    }
}

fun Noise2d.Companion.layered(noise: Noise2d,
                              amplitude: Float = 1f,
                              scale: Float = 1f,
                              center: Vec2f = Vec2f.ZERO) = ScaledNoise2d(noise, amplitude, scale, center)